package com.example.classmanageapp.utils;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.example.classmanageapp.R;

public class SysUtils {


    public static Integer currentColor = 1;


    /**
     * 设置 Activity 状态栏
     * @param activity
     * @param isFullScreen
     * @param statusColor
     */
    public static void setStatusBarColor(Activity activity, boolean isFullScreen, int statusColor) {
        Window window = activity.getWindow();
        //设置状态栏颜色 Color.TRANSPARENT
        window.setStatusBarColor(statusColor);
        //设置系统状态栏处于可见状态
        if (isFullScreen) {
            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }else {
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }

    // 更换皮肤
    public static void changeSkin(Activity activity){
        currentColor = (currentColor + 1) % 2;
        setSkin(activity, currentColor);
    }


    public static void setSkin(Activity activity){
        setSkin(activity, -1);
    }

    // 设置皮肤
    public static void setSkin(Activity activity, int color){

        if (color != -1) {
            currentColor = color;
        }

        if(currentColor == 0){
            /*设置当前Activity的背景色*/
            Resources res = activity.getResources();
            Drawable drawable = res.getDrawable(R.drawable.main_back_color_red);
            activity.getWindow().setBackgroundDrawable(drawable);
        }else if (currentColor == 1){
            /*设置当前Activity的背景色*/
            Resources res = activity.getResources();
            Drawable drawable = res.getDrawable(R.drawable.main_back_color_blue);
            activity.getWindow().setBackgroundDrawable(drawable);
        }


    }

}
